// pages/order/order.js
import { request } from "../../request/index.js";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    collect: [],
    tabs: [{
      id: 0,
      value: '商品收藏',
      isActive: true
    },
    {
      id: 1,
      value: '品牌收藏',
      isActive: false
    },
    {
      id: 2,
      value: '店铺收藏',
      isActive: false
    },
    {
      id: 3,
      value: '浏览足迹',
      isActive: false
    }
    ]
  },

  //根据标题索引来激活选中的标题数组
  changeTitleByIndex(index) {
    // 2.修改原数组
    console.log(this.data);
    let { tabs } = this.data
    //赋值 到data
    tabs.forEach((v, i) => i == index ? v.isActive = true : v.isActive = false);
    this.setData({
      tabs
    })
  },
  //从子组件传过来
  handleTabsItemChange(e) {
    // console.log(e);
    //1.获取点击的索引
    const { index } = e.detail
    //修改原数组
    let {tabs}=this.data
    tabs.forEach((v,i)=>i==index?v.isActive=true:v.isActive=false)
  },
  onShow(){
    const collect=wx.getStorageSync('collect')
    this.setData({
      collect
    })
  }
})